package com.fanketly.funacg2.data.model


import com.google.gson.annotations.SerializedName
import com.lzx.starrysky.SongInfo

fun SongInfo.convertToWork() =
    WorkList.Work(id = artist.toInt(), thumbnailCoverUrl = songCover, title = songName)


@kotlinx.serialization.Serializable
data class WorkList(
    @SerializedName("pagination")
    val pagination: Pagination = Pagination(),
    @SerializedName("works")
    val works: List<Work> = listOf(),
) {
    @kotlinx.serialization.Serializable
    data class Pagination(
        @SerializedName("currentPage")
        val currentPage: Int = 0,
        @SerializedName("pageSize")
        val pageSize: Int = 0,
        @SerializedName("totalCount")
        val totalCount: Int = 0,
    )

    @kotlinx.serialization.Serializable
    data class Work(
        @SerializedName("circle")
        val circle: Circle = Circle(),
        @SerializedName("circle_id")
        val circleId: Int = 0,
        @SerializedName("create_date")
        val createDate: String = "",
        @SerializedName("dl_count")
        val dlCount: Int = 0,
        @SerializedName("has_subtitle")
        val hasSubtitle: Boolean = false,
        @SerializedName("id")
        val id: Int = 0,
        @SerializedName("mainCoverUrl")
        val mainCoverUrl: String = "",
        @SerializedName("name")
        val name: String = "",
        @SerializedName("nsfw")
        val nsfw: Boolean = false,
        @SerializedName("price")
        val price: Int = 0,
        @SerializedName("rank")
        val rank: List<Rank>? = listOf(),
        @SerializedName("rate_average_2dp")
        val rateAverage2dp: Double = 0.0,
        @SerializedName("rate_count")
        val rateCount: Int = 0,
        @SerializedName("rate_count_detail")
        val rateCountDetail: List<RateCountDetail> = listOf(),
        @SerializedName("release")
        val release: String = "",
        @SerializedName("review_count")
        val reviewCount: Int = 0,
        @SerializedName("samCoverUrl")
        val samCoverUrl: String = "",
        @SerializedName("tags")
        val tags: List<Tag> = listOf(),
        @SerializedName("thumbnailCoverUrl")
        val thumbnailCoverUrl: String = "",
        @SerializedName("title")
        val title: String = "",
        @SerializedName("userRating")
        val userRating: Int? = 0,
        @SerializedName("vas")
        val vas: List<Va> = listOf(),
    ) {
        @kotlinx.serialization.Serializable
        data class Circle(
            @SerializedName("id")
            val id: Int = 0,
            @SerializedName("name")
            val name: String = "",
        )

        @kotlinx.serialization.Serializable
        data class Rank(
            @SerializedName("category")
            val category: String = "",
            @SerializedName("rank")
            val rank: Int = 0,
            @SerializedName("rank_date")
            val rankDate: String = "",
            @SerializedName("term")
            val term: String = "",
        )

        @kotlinx.serialization.Serializable
        data class RateCountDetail(
            @SerializedName("count")
            val count: Int = 0,
            @SerializedName("ratio")
            val ratio: Int = 0,
            @SerializedName("review_point")
            val reviewPoint: Int = 0,
        )

        @kotlinx.serialization.Serializable
        data class Tag(
            @SerializedName("i18n")
            val i18n: I18n = I18n(),
            @SerializedName("id")
            val id: Int = 0,
            @SerializedName("name")
            val name: String = "",
        ) {
            @kotlinx.serialization.Serializable
            data class I18n(
                @SerializedName("en-us")
                val enUs: EnUs = EnUs(),
                @SerializedName("ja-jp")
                val jaJp: JaJp = JaJp(),
                @SerializedName("zh-cn")
                val zhCn: ZhCn = ZhCn(),
            ) {
                @kotlinx.serialization.Serializable
                data class EnUs(
                    @SerializedName("name")
                    val name: String = "",
                )

                @kotlinx.serialization.Serializable
                data class JaJp(
                    @SerializedName("name")
                    val name: String = "",
                )

                @kotlinx.serialization.Serializable
                data class ZhCn(
                    @SerializedName("name")
                    val name: String = "",
                )
            }
        }

        @kotlinx.serialization.Serializable
        data class Va(
            @SerializedName("id")
            val id: String = "",
            @SerializedName("name")
            val name: String = "",
        )

        override fun toString(): String {
            return "Work(circle=$circle, circleId=$circleId, createDate='$createDate', dlCount=$dlCount, hasSubtitle=$hasSubtitle, id=$id, mainCoverUrl='$mainCoverUrl', name='$name', nsfw=$nsfw, price=$price, rank=$rank, rateAverage2dp=$rateAverage2dp, rateCount=$rateCount, rateCountDetail=$rateCountDetail, release='$release', reviewCount=$reviewCount, samCoverUrl='$samCoverUrl', tags=$tags, thumbnailCoverUrl='$thumbnailCoverUrl', title='$title', userRating=$userRating, vas=$vas)"
        }

    }
}